var businessInOut = {};
businessInOut.methods = {};

$(function(){

    // 标题切换
    businessInOut.methods.inOutTab();

    // 收支记录列表
    businessInOut.methods.dataGrid();

    var year = new Date().getFullYear();//Current year.
    new Controller.DateSelect({
        content: ".shop-right-order",
        event: "hover",
        // callback: function (selected) {
        //     vm.selectedStatus(selected);
        //     vm.refresh();
        // },
        list: [{ name: "近三个月明细", value: "0" }, { name: "今日明细", value: "1" }, { name: year + "年明细", value: "2" }, { name: year+"年以前明细", value: "3" }],
    });


    // 分页
    var page = new Controller.PageControl();
    page.init({
        totalCount:20,    //总页数
        conter:".shop-page",    //容器选择器
        nowPage:1,        //当前页，默认第几页
        //callback:fun,       //点击回调
        // gotoCallBack:fun    //跳转回调
    });

})


// 收支记录列表
businessInOut.methods.dataGrid = function(){
    var d = [
        {CreatedTimeString:"2018-08-06 16:47:36",WaresQty:"+1900",ID:"转入",ShopMessage:"订单返余额(原返返现) 订单号：77095545555,退款理由：null, 审核备注：null,返款金额：127.930, 退款途径：原返"},
        {CreatedTimeString:"2018-08-06 16:47:36",WaresQty:"-1900",ID:"转出",ShopMessage:"订单返余额(原返返现) 订单号：77095545555,退款理由：null, 审核备注：null,返款金额：127.930, 退款途径：原返"},
        {CreatedTimeString:"2018-08-06 16:47:36",WaresQty:"+1900",ID:"转入",ShopMessage:"订单返余额(原返返现) 订单号：77095545555,退款理由：null, 审核备注：null,返款金额：127.930, 退款途径：原返"},
        {CreatedTimeString:"2018-08-06 16:47:36",WaresQty:"-1900",ID:"转出",ShopMessage:"订单返余额(原返返现) 订单号：77095545555,退款理由：null, 审核备注：null,返款金额：127.930, 退款途径：原返"},
        {CreatedTimeString:"2018-08-06 16:47:36",WaresQty:"+1900",ID:"转入",ShopMessage:"订单返余额(原返返现) 订单号：77095545555,退款理由：null, 审核备注：null,返款金额：127.930, 退款途径：原返"}
    ]
    Controller.GridControl.Bind(d, ".shop-inOut-records-con", {
        CreatedTimeString:{
            cnName: "时间",
            index: 0,
            width:"162px"
        },
        WaresQty: {
            cnName: "金额",
            index: 1,
            width:"112px",
            converter:jeConvert
        },
        ID: {
            cnName: "操作",
            index: 2,
            width:"173px"
        },
        ShopMessage: {
            cnName: "备注",
            index: 3,
            width:"493px",
            converter:bzConvert
        }
    },false,false); 
}
//转换器
function jeConvert(val) {
    if(Number(val) >= 0){
        return '<div class="shop-inOut-records-je shop-inOut-records-jePlus">'+ val +'</div>';
    }else{
        return '<div class="shop-inOut-records-je shop-inOut-records-jeMinus">'+ val +'</div>';
    }
    
}
function bzConvert(val){
    var _html = '<div class="shop-inOut-records-bz">'+ val +'</div>';
    return _html;
}



// 标题切换
businessInOut.methods.inOutTab = function(){
    $(".shop-inOut-smallTitle-cut").on("click","li",function(){
        $(this).addClass("shop-click").siblings().removeClass("shop-click");
    })
}